{extend name="public:layout" /}
{block name="title"}{$moudleName}列表{/block}
{block name="head"}
	<style>
		.leave_layer p {height: 40px;line-height: 40px;}
	</style>
{/block}
{block name="body"}
<div class="wrapper wrapper-content">
    <div class="ibox">
        <div class="ibox-title">
            <ol class="breadcrumb">
                <ol class="breadcrumb">
                    <li class="active"><i class="fa fa-hand-o-right"></i> 正在进行中行程单</li>
                </ol>
            </ol>
            <div class="clearfix"></div>
        </div>
        <div class="ibox-content">
            <div class="alert alert-danger">
                <p>1、只有正在行程中得车辆才可以进行插单</p>
                <p>2、插单费用必须在该次大行程中一次性结清，否则视为新的行程需重新发起行程</p>
                <p>3、插单费用在该次行程结算时体现，该费用最终体现在统计数据中</p>
            </div>
            <div id="buttons">
                <form class="form-inline" id="searchForm" method="post">
                    <div class="form-group">
                        <div class="input-group">
                            <input class="form-control" type="text" placeholder="请输入车牌号" name="car_sn" />
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="input-group">
                            <input class="form-control" type="text" placeholder="请输入司机姓名" name="fleet_driver" />
                        </div>
                    </div>
                    <button type="button" class="btn btn-info" onclick="refresh()"><i class="fa fa-search"></i> 搜索</button>
                    <a class="btn btn-white" href="{:url('index',['mid'=>$Request.param.mid])}">
                        <i class="fa fa-trash"></i> 清空
                    </a>
                </form>
            </div>
            <table class="table table-bordered" id="grid"></table>
        </div>
    </div>
</div>
{/block}
{block name="script"}
<script type="text/javascript">
    $(function () {
        //列定义
        var columnsData=[
            {field: 'state', checkbox:true,},
            {field: 'aid', title: '订单',width:60,sortable:true},
            {field: 'car_sn', title: '车辆',formatter:function (value,row,index) {
                var html='';
                if(row.btype_aid==1){
                    html='<span class="label label-success" style="display:block;font-size:18px;padding:10px 8px;margin:5px;font-weight:500;">'+row.car_sn+'</span>';
                }else{
                    html='<span class="label label-warning" style="display:block;font-size:18px;padding:10px 8px;margin:5px;font-weight:500;">'+row.car_sn+'</span>';
                }
                return html;
            }},
            {field: 'title', title: '行程单',formatter:function (value,row,index) {
                if(row.order_delay>0){
                    return row.title+'('+row.order_odd+')'+' <span class="label label-danger">延期'+row.order_delay+'天</span>';
                }
                return row.title+'('+row.order_odd+')';
            }},
            {field: 'order_charge', title: '订单金额',sortable:true},
            {field: 'order_advance', title: '预付款',sortable:true},
            {field: 'order_pay', title: '已付款',sortable:true},
            {field: 'order_start_time', title: '出发时间',sortable:true,
                formatter:function (value,row,index) {
                    return value.substring(0,16);
                }
            },
            {field: 'order_end_time', title: '结束时间',sortable:true,
                formatter:function (value,row,index) {
                    return value.substring(0,16);
                }
            },
            {field: 'fleet_driver', title: '驾驶员'},
            {field: 'operate', title: '操作', width:150, align: 'center',
                formatter:function (value,row,index) {
                    var html='';
                    html+='<a href="/system/logic.order/insertorder.html?aid='+row.aid+'&mid='+row.mid+'" class="btn btn-primary btn-xs">插入短途行程</a> ';
                    return html;
                }
            }
        ];
        In('btable', function () {
            $('#grid').bootstrapTable({
                showColumns:true,
                url: '__URL__/pagelist.html?mid={$Request.param.mid}&car_status=1',
                toolbar:'#buttons',
                sortName:'aid',
                sortOrder:'desc',
                method:'post',
                pagination:true,
                queryParamsType:'page',
                sidePagination:'server',
                pageSize:60, //每页记录数
                showRefresh:true, //显示刷新按钮
                showToggle:true, //显示切换视图按钮
                showPaginationSwitch:true, //显示数据条数选择框
                idField:'aid', //主键列
                clickToSelect:true, //设置true 将在点击行时，自动选择rediobox 和 checkbox
                singleSelect:false, //设置true 将禁止多选
                maintainSelected:true, //设置为true 将记住选择项
                queryParams:function (params) {
                    params.op="{$Request.param.op}";
                    params.car_sn=$("input[name='car_sn']").val();
                    params.fleet_driver=$("input[name='fleet_driver']").val();
                    params.short_status="{$Request.param.short_status}";
                    return params;
                },
                columns: columnsData
            });
        });
    });
    //刷新表格
    function refresh() {
        $('#grid').bootstrapTable('refresh');
    }
</script>
{/block}